package com.csii.ssm;


import com.csii.ssm.virwebservice.SvcServiceStub;
import com.csii.ssm.virwebservice.SvcServiceStub.SvcInfo;
import com.csii.ssm.virwebservice.SvcServiceStub.TransX;
import com.csii.ssm.virwebservice.SvcServiceStub.TransXResponse;
import org.apache.axis2.AxisFault;
import org.apache.axis2.client.Options;

import java.rmi.RemoteException;

/**
 * Created by Charis on 2016/9/5.
 */
public class WebServiceTest {
    public static void main(String[] args) {
        // System.setProperty("javax.net.ssl.keyStore",
        // "E:\\keystore\\server.ks");
        // System.setProperty("javax.net.ssl.keyStorePassword", "123456");
        // System.setProperty("javax.net.ssl.trustStore",
        // "E:\\keystore\\server.ks");
        // System.setProperty("javax.net.ssl.trustStorePassword", "123456");

        SvcServiceStub s = null;
        try {
            s = new SvcServiceStub();
            Options options = s._getServiceClient().getOptions();
            options.setTimeOutInMilliSeconds(90000000);// 设置超时(单位是毫秒)

//             s._getServiceClient().addHeader(createHeaderOMElement());
            s._getServiceClient().setOptions(options);
            TransX t = new TransX();

            SvcInfo svc = new SvcInfo();
           /* svc.setTxnId("X");
            svc.setPan("600138100000XXXX");
            svc.setPinData("067621");
            svc.setMid("888888888888888");
            svc.setTid("88888888");
            svc.setVoucher("20160809-009");
            svc.setMemo("haha");

            ArrayOfAccount ba = new ArrayOfAccount();
            Account a0 = new Account();
            a0.setPan("600138100000XXXX");
            a0.setAccno("XXXXXXX");
            a0.setBalAmt("50.00");
            ba.addAccount(a0);

            Account a1 = new Account();
            a1.setPan("600138100000XXXX");
            a1.setAccno("XXXXXXX");
            a1.setBalAmt("50.00");
            ba.addAccount(a1);*/

            svc.setTxnId("161");
            svc.setChnl("04");
            svc.setAccno("32318493214");
            svc.setSystrace("432543");
            svc.setOrgCode("00195");
            svc.setTeller("001");

            t.setIn0(svc);
            TransXResponse rs = s.transX(t);
            SvcInfo rsvc = rs.getOut();
            /*ArrayOfAccount arr = rsvc.getAccList();
            for (SvcServiceStub.Account a : arr.getAccount()) {
                System.out.println(a.getAccno());
            }
            System.out.println(rsvc.getRc() + ":" + rsvc.getRcDetail());*/
        } catch (AxisFault axisFault) {
            axisFault.printStackTrace();
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }
}
